﻿using System;
using Soundteller.Audio.Model;
using Soundteller.Audio.Model.Interfaces;
using Soundteller.Audio.Repositories.Interfaces;
using System.Diagnostics;

namespace Soundteller.Audio.Repositories
{
    public class SoundBufferRepository : MemoryRepositoryBase, ISoundBufferRepository
    {
        public SoundBufferRepository(IMemoryContext context)
            : base(context)
        {
        }

        public Sound Pop()
        {
            return Context.SoundBuffer.Pop();
        }

        public void Push(Sound sound)
        {
            if (sound == null) throw new ArgumentNullException("sound");

            Context.SoundBuffer.Push(sound);
        }

        public Sound Peek()
        {
            if (Context.SoundBuffer.Count == 0) return null;
            
            return Context.SoundBuffer.Peek();
        }

        public bool Contains(Sound sound)
        {
            if (sound == null) throw new ArgumentNullException("sound");

            return Context.SoundBuffer.Contains(sound);
        }
    }
}
